<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* asn1csr-1.0.6.js (c) 2015-2018 Kenji Urushima | kjur.github.com/jsrsasign/license
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * asn1csr.js - ASN.1 DER encoder classes for PKCS#10 CSR
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * Copyright (c) 2015-2018 Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * This software is licensed under the terms of the MIT License.
<span class='line'>  9</span>  * https://kjur.github.io/jsrsasign/license
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * The above copyright and license notice shall be 
<span class='line'> 12</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 13</span>  */</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span>  * @fileOverview
<span class='line'> 17</span>  * @name asn1csr-1.0.js
<span class='line'> 18</span>  * @author Kenji Urushima kenji.urushima@gmail.com
<span class='line'> 19</span>  * @version jsrsasign 8.0.5 asn1csr 1.0.6 (2018-Jan-13)
<span class='line'> 20</span>  * @since jsrsasign 4.9.0
<span class='line'> 21</span>  * @license &lt;a href="https://kjur.github.io/jsrsasign/license/">MIT License&lt;/a>
<span class='line'> 22</span>  */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="COMM">/**
<span class='line'> 25</span>  * kjur's ASN.1 class for CSR/PKCS#10 name space
<span class='line'> 26</span>  * &lt;p>
<span class='line'> 27</span>  * This name space is a sub name space for {@link KJUR.asn1}.
<span class='line'> 28</span>  * This name space contains classes for
<span class='line'> 29</span>  * &lt;a href="https://tools.ietf.org/html/rfc2986">RFC 2986&lt;/a>
<span class='line'> 30</span>  * certificate signing request(CSR/PKCS#10) and its utilities
<span class='line'> 31</span>  * to be issued your certificate from certification authorities.
<span class='line'> 32</span>  * &lt;h4>PROVIDING ASN.1 STRUCTURES&lt;/h4>
<span class='line'> 33</span>  * &lt;ul>
<span class='line'> 34</span>  * &lt;li>{@link KJUR.asn1.csr.CertificationRequest}&lt;/li>
<span class='line'> 35</span>  * &lt;li>{@link KJUR.asn1.csr.CertificationRequestInfo}&lt;/li>
<span class='line'> 36</span>  * &lt;/ul>
<span class='line'> 37</span>  * &lt;h4>PROVIDING UTILITY CLASSES&lt;/h4>
<span class='line'> 38</span>  * &lt;ul>
<span class='line'> 39</span>  * &lt;li>{@link KJUR.asn1.csr.CSRUtil}&lt;/li>
<span class='line'> 40</span>  * &lt;/ul>
<span class='line'> 41</span>  * {@link KJUR.asn1.csr.CSRUtil.newCSRPEM} method is very useful to
<span class='line'> 42</span>  * get your certificate signing request (CSR/PKCS#10) file.
<span class='line'> 43</span>  * &lt;/p>
<span class='line'> 44</span>  * @name KJUR.asn1.csr
<span class='line'> 45</span>  * @namespace
<span class='line'> 46</span>  */</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1.csr</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.asn1.csr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1.csr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> 
<span class='line'> 49</span> </span><span class="COMM">/**
<span class='line'> 50</span>  * ASN.1 CertificationRequest structure class
<span class='line'> 51</span>  * @name KJUR.asn1.csr.CertificationRequest
<span class='line'> 52</span>  * @class ASN.1 CertificationRequest structure class
<span class='line'> 53</span>  * @param {Array} params associative array of parameters (ex. {})
<span class='line'> 54</span>  * @extends KJUR.asn1.ASN1Object
<span class='line'> 55</span>  * @since jsrsasign 4.9.0 asn1csr 1.0.0
<span class='line'> 56</span>  * @description
<span class='line'> 57</span>  * &lt;br/>
<span class='line'> 58</span>  * @example
<span class='line'> 59</span>  * csri = new KJUR.asn1.csr.CertificationRequestInfo();
<span class='line'> 60</span>  * csri.setSubjectByParam({'str': '/C=US/O=Test/CN=example.com'});
<span class='line'> 61</span>  * csri.setSubjectPublicKeyByGetKey(pubKeyObj);
<span class='line'> 62</span>  * csr = new KJUR.asn1.csr.CertificationRequest({'csrinfo': csri});
<span class='line'> 63</span>  * csr.sign("SHA256withRSA", prvKeyObj);
<span class='line'> 64</span>  * pem = csr.getPEMString();
<span class='line'> 65</span>  * 
<span class='line'> 66</span>  * // -- DEFINITION OF ASN.1 SYNTAX --
<span class='line'> 67</span>  * // CertificationRequest ::= SEQUENCE {
<span class='line'> 68</span>  * //   certificationRequestInfo CertificationRequestInfo,
<span class='line'> 69</span>  * //   signatureAlgorithm       AlgorithmIdentifier{{ SignatureAlgorithms }},
<span class='line'> 70</span>  * //   signature                BIT STRING }
<span class='line'> 71</span>  * //
<span class='line'> 72</span>  * // CertificationRequestInfo ::= SEQUENCE {
<span class='line'> 73</span>  * //   version       INTEGER { v1(0) } (v1,...),
<span class='line'> 74</span>  * //   subject       Name,
<span class='line'> 75</span>  * //   subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
<span class='line'> 76</span>  * //   attributes    [0] Attributes{{ CRIAttributes }} }
<span class='line'> 77</span>  */</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="NAME">KJUR.asn1.csr.CertificationRequest</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.asn1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">	</span><span class="NAME">_DERBitString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERBitString</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">	</span><span class="NAME">_DERSequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERSequence</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1_csr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.csr</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1_x509</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.x509</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="NAME">_KJUR_asn1_csr.CertificationRequest.superclass.constructor.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> 
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">asn1CSRInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">asn1SignatureAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">asn1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hexSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prvKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> 
<span class='line'> 94</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 95</span>      * sign CertificationRequest and set signature value internally&lt;br/>
<span class='line'> 96</span>      * @name sign
<span class='line'> 97</span>      * @memberOf KJUR.asn1.csr.CertificationRequest#
<span class='line'> 98</span>      * @function
<span class='line'> 99</span>      * @description
<span class='line'>100</span>      * This method self-signs CertificateRequestInfo with a subject's
<span class='line'>101</span>      * private key and set signature value internally.
<span class='line'>102</span>      * &lt;br/>
<span class='line'>103</span>      * @example
<span class='line'>104</span>      * csr = new KJUR.asn1.csr.CertificationRequest({'csrinfo': csri});
<span class='line'>105</span>      * csr.sign("SHA256withRSA", prvKeyObj);
<span class='line'>106</span>      */</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="NAME">this.sign</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sigAlgName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prvKeyObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.prvKey</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">this.prvKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">prvKeyObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> 
<span class='line'>110</span> </span><span class="WHIT">	</span><span class="NAME">this.asn1SignatureAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> 
<span class='line'>111</span> 	    </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_x509.AlgorithmIdentifier</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'name'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlgName</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> 
<span class='line'>113</span> </span><span class="WHIT">        </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR.crypto.Signature</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlgName</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">        </span><span class="NAME">sig.init</span><span class="PUNC">(</span><span class="NAME">this.prvKey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">        </span><span class="NAME">sig.updateHex</span><span class="PUNC">(</span><span class="NAME">this.asn1CSRInfo.getEncodedHex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">        </span><span class="NAME">this.hexSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.sign</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> 
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERBitString</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'hex'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'00'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.hexSig</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">seq</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERSequence</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'array'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">this.asn1CSRInfo</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">                                              </span><span class="NAME">this.asn1SignatureAlg</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">                                              </span><span class="NAME">this.asn1Sig</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">        </span><span class="NAME">this.hTLV</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">seq.getEncodedHex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">        </span><span class="NAME">this.isModified</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> 
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>127</span>      * get PEM formatted certificate signing request (CSR/PKCS#10)&lt;br/>
<span class='line'>128</span>      * @name getPEMString
<span class='line'>129</span>      * @memberOf KJUR.asn1.csr.CertificationRequest#
<span class='line'>130</span>      * @function
<span class='line'>131</span>      * @return PEM formatted string of CSR/PKCS#10
<span class='line'>132</span>      * @description
<span class='line'>133</span>      * This method is to a get CSR PEM string after signed.
<span class='line'>134</span>      * &lt;br/>
<span class='line'>135</span>      * @example
<span class='line'>136</span>      * csr = new KJUR.asn1.csr.CertificationRequest({'csrinfo': csri});
<span class='line'>137</span>      * csr.sign();
<span class='line'>138</span>      * pem =  csr.getPEMString();
<span class='line'>139</span>      * // pem will be following:
<span class='line'>140</span>      * // -----BEGIN CERTIFICATE REQUEST-----
<span class='line'>141</span>      * // MII ...snip...
<span class='line'>142</span>      * // -----END CERTIFICATE REQUEST-----
<span class='line'>143</span>      */</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">    </span><span class="NAME">this.getPEMString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextopem</span><span class="PUNC">(</span><span class="NAME">this.getEncodedHex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"CERTIFICATE REQUEST"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> 
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="NAME">this.getEncodedHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isModified</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.hTLV</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hTLV</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"not signed yet"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> 
<span class='line'>153</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">params.csrinfo</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1CSRInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">params.csrinfo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>156</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="NAME">YAHOO.lang.extend</span><span class="PUNC">(</span><span class="NAME">KJUR.asn1.csr.CertificationRequest</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1.ASN1Object</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> 
<span class='line'>159</span> </span><span class="COMM">/**
<span class='line'>160</span>  * ASN.1 CertificationRequestInfo structure class
<span class='line'>161</span>  * @name KJUR.asn1.csr.CertificationRequestInfo
<span class='line'>162</span>  * @class ASN.1 CertificationRequestInfo structure class
<span class='line'>163</span>  * @param {Array} params associative array of parameters (ex. {})
<span class='line'>164</span>  * @extends KJUR.asn1.ASN1Object
<span class='line'>165</span>  * @since jsrsasign 4.9.0 asn1csr 1.0.0
<span class='line'>166</span>  * @description
<span class='line'>167</span>  * &lt;pre>
<span class='line'>168</span>  * // -- DEFINITION OF ASN.1 SYNTAX --
<span class='line'>169</span>  * // CertificationRequestInfo ::= SEQUENCE {
<span class='line'>170</span>  * //   version       INTEGER { v1(0) } (v1,...),
<span class='line'>171</span>  * //   subject       Name,
<span class='line'>172</span>  * //   subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
<span class='line'>173</span>  * //   attributes    [0] Attributes{{ CRIAttributes }} }
<span class='line'>174</span>  * &lt;/pre>
<span class='line'>175</span>  * &lt;br/>
<span class='line'>176</span>  * @example
<span class='line'>177</span>  * csri = new KJUR.asn1.csr.CertificationRequestInfo();
<span class='line'>178</span>  * csri.setSubjectByParam({'str': '/C=US/O=Test/CN=example.com'});
<span class='line'>179</span>  * csri.setSubjectPublicKeyByGetKey(pubKeyObj);
<span class='line'>180</span>  */</span><span class="WHIT">
<span class='line'>181</span> </span><span class="NAME">KJUR.asn1.csr.CertificationRequestInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.asn1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">	</span><span class="NAME">_DERInteger</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERInteger</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">	</span><span class="NAME">_DERSequence</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERSequence</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">	</span><span class="NAME">_DERSet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERSet</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">	</span><span class="NAME">_DERNull</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERNull</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">	</span><span class="NAME">_DERTaggedObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERTaggedObject</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">	</span><span class="NAME">_DERObjectIdentifier</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.DERObjectIdentifier</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1_csr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.csr</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1_x509</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1.x509</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">	</span><span class="NAME">_X500Name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_x509.X500Name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">	</span><span class="NAME">_Extension</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_x509.Extension</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">	</span><span class="NAME">_KEYUTIL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KEYUTIL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> 
<span class='line'>196</span> </span><span class="WHIT">    </span><span class="NAME">_KJUR_asn1_csr.CertificationRequestInfo.superclass.constructor.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> 
<span class='line'>198</span> </span><span class="WHIT">    </span><span class="NAME">this._initialize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> 
<span class='line'>201</span> </span><span class="WHIT">	</span><span class="NAME">this.asn1Version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERInteger</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'int'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">	</span><span class="NAME">this.asn1Subject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">	</span><span class="NAME">this.asn1SubjPKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">	</span><span class="NAME">this.extensionsArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> 
<span class='line'>207</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>208</span>      * set subject name field by parameter
<span class='line'>209</span>      * @name setSubjectByParam
<span class='line'>210</span>      * @memberOf KJUR.asn1.csr.CertificationRequestInfo#
<span class='line'>211</span>      * @function
<span class='line'>212</span>      * @param {Array} x500NameParam X500Name parameter
<span class='line'>213</span>      * @description
<span class='line'>214</span>      * @example
<span class='line'>215</span>      * csri.setSubjectByParam({'str': '/C=US/CN=b'});
<span class='line'>216</span>      * @see KJUR.asn1.x509.X500Name
<span class='line'>217</span>      */</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">    </span><span class="NAME">this.setSubjectByParam</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x500NameParam</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Subject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_X500Name</span><span class="PUNC">(</span><span class="NAME">x500NameParam</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>223</span>      * set subject public key info by RSA/ECDSA/DSA key parameter
<span class='line'>224</span>      * @name setSubjectPublicKeyByGetKey
<span class='line'>225</span>      * @memberOf KJUR.asn1.csr.CertificationRequestInfo#
<span class='line'>226</span>      * @function
<span class='line'>227</span>      * @param {Object} keyParam public key parameter which passed to {@link KEYUTIL.getKey} argument
<span class='line'>228</span>      * @description
<span class='line'>229</span>      * @example
<span class='line'>230</span>      * csri.setSubjectPublicKeyByGetKeyParam(certPEMString); // or 
<span class='line'>231</span>      * csri.setSubjectPublicKeyByGetKeyParam(pkcs8PublicKeyPEMString); // or 
<span class='line'>232</span>      * csir.setSubjectPublicKeyByGetKeyParam(kjurCryptoECDSAKeyObject); // et.al.
<span class='line'>233</span>      * @see KJUR.asn1.x509.SubjectPublicKeyInfo
<span class='line'>234</span>      * @see KEYUTIL.getKey
<span class='line'>235</span>      */</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">    </span><span class="NAME">this.setSubjectPublicKeyByGetKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">keyParam</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keyObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KEYUTIL.getKey</span><span class="PUNC">(</span><span class="NAME">keyParam</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1SubjPKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> 
<span class='line'>239</span> 	    </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_x509.SubjectPublicKeyInfo</span><span class="PUNC">(</span><span class="NAME">keyObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> 
<span class='line'>242</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>243</span>      * append X.509v3 extension to this object by name and parameters
<span class='line'>244</span>      * @name appendExtensionByName
<span class='line'>245</span>      * @memberOf KJUR.asn1.csr.CertificationRequestInfo#
<span class='line'>246</span>      * @function
<span class='line'>247</span>      * @param {name} name name of X.509v3 Extension object
<span class='line'>248</span>      * @param {Array} extParams parameters as argument of Extension constructor.
<span class='line'>249</span>      * @see KJUR.asn1.x509.Extension
<span class='line'>250</span>      * @description
<span class='line'>251</span>      * @example
<span class='line'>252</span>      * var o = new KJUR.asn1.csr.CertificationRequestInfo();
<span class='line'>253</span>      * o.appendExtensionByName('BasicConstraints', {'cA':true, 'critical': true});
<span class='line'>254</span>      * o.appendExtensionByName('KeyUsage', {'bin':'11'});
<span class='line'>255</span>      * o.appendExtensionByName('CRLDistributionPoints', {uri: 'http://aaa.com/a.crl'});
<span class='line'>256</span>      * o.appendExtensionByName('ExtKeyUsage', {array: [{name: 'clientAuth'}]});
<span class='line'>257</span>      * o.appendExtensionByName('AuthorityKeyIdentifier', {kid: '1234ab..'});
<span class='line'>258</span>      * o.appendExtensionByName('AuthorityInfoAccess', {array: [{accessMethod:{oid:...},accessLocation:{uri:...}}]});
<span class='line'>259</span>      */</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">    </span><span class="NAME">this.appendExtensionByName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">extParams</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">	</span><span class="NAME">_Extension.appendByNameToArray</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">				       </span><span class="NAME">extParams</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">				       </span><span class="NAME">this.extensionsArray</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> 
<span class='line'>266</span> </span><span class="WHIT">    </span><span class="NAME">this.getEncodedHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> 
<span class='line'>269</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Array.push</span><span class="PUNC">(</span><span class="NAME">this.asn1Version</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Array.push</span><span class="PUNC">(</span><span class="NAME">this.asn1Subject</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">        </span><span class="NAME">this.asn1Array.push</span><span class="PUNC">(</span><span class="NAME">this.asn1SubjPKey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> 
<span class='line'>273</span> </span><span class="WHIT">	</span><span class="COMM">// extensionRequest</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.extensionsArray.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extSeq</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERSequence</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">array</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.extensionsArray</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extSet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERSet</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">array</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">extSeq</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extSeq2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERSequence</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">array</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">		</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERObjectIdentifier</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">oid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"1.2.840.113549.1.9.14"</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">		</span><span class="NAME">extSet</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">	    </span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extTagObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERTaggedObject</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">		</span><span class="NAME">explicit</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">		</span><span class="NAME">tag</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'a0'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">		</span><span class="NAME">obj</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">extSeq2</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">            </span><span class="NAME">this.asn1Array.push</span><span class="PUNC">(</span><span class="NAME">extTagObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extTagObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERTaggedObject</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">		</span><span class="NAME">explicit</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">		</span><span class="NAME">tag</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'a0'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">		</span><span class="NAME">obj</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERNull</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">            </span><span class="NAME">this.asn1Array.push</span><span class="PUNC">(</span><span class="NAME">extTagObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>295</span> 
<span class='line'>296</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_DERSequence</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">"array"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.asn1Array</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">        </span><span class="NAME">this.hTLV</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.getEncodedHex</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">        </span><span class="NAME">this.isModified</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.hTLV</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>301</span> 
<span class='line'>302</span> </span><span class="WHIT">    </span><span class="NAME">this._initialize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> </span><span class="NAME">YAHOO.lang.extend</span><span class="PUNC">(</span><span class="NAME">KJUR.asn1.csr.CertificationRequestInfo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1.ASN1Object</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>305</span> 
<span class='line'>306</span> </span><span class="COMM">/**
<span class='line'>307</span>  * Certification Request (CSR/PKCS#10) utilities class&lt;br/>
<span class='line'>308</span>  * @name KJUR.asn1.csr.CSRUtil
<span class='line'>309</span>  * @class Certification Request (CSR/PKCS#10) utilities class
<span class='line'>310</span>  * @description
<span class='line'>311</span>  * This class provides utility static methods for CSR/PKCS#10.
<span class='line'>312</span>  * Here is a list of methods:
<span class='line'>313</span>  * &lt;ul>
<span class='line'>314</span>  * &lt;li>{@link KJUR.asn1.csr.CSRUtil.newCSRPEM}&lt;/li>
<span class='line'>315</span>  * &lt;li>{@link KJUR.asn1.csr.CSRUtil.getInfo}&lt;/li>
<span class='line'>316</span>  * &lt;/ul>
<span class='line'>317</span>  * &lt;br/>
<span class='line'>318</span>  */</span><span class="WHIT">
<span class='line'>319</span> </span><span class="NAME">KJUR.asn1.csr.CSRUtil</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>320</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> 
<span class='line'>322</span> </span><span class="COMM">/**
<span class='line'>323</span>  * generate a PEM format of CSR/PKCS#10 certificate signing request
<span class='line'>324</span>  * @name newCSRPEM
<span class='line'>325</span>  * @memberOf KJUR.asn1.csr.CSRUtil
<span class='line'>326</span>  * @function
<span class='line'>327</span>  * @param {Array} param parameter to generate CSR
<span class='line'>328</span>  * @since jsrsasign 4.9.0 asn1csr 1.0.0
<span class='line'>329</span>  * @description
<span class='line'>330</span>  * This method can generate a CSR certificate signing
<span class='line'>331</span>  * request by a simple JSON object which has following parameters:
<span class='line'>332</span>  * &lt;ul>
<span class='line'>333</span>  * &lt;li>subject - parameter to be passed to {@link KJUR.asn1.x509.X500Name}&lt;/li>
<span class='line'>334</span>  * &lt;li>sbjpubkey - parameter to be passed to {@link KEYUTIL.getKey}&lt;/li>
<span class='line'>335</span>  * &lt;li>sigalg - signature algorithm name (ex. SHA256withRSA)&lt;/li>
<span class='line'>336</span>  * &lt;li>sbjprvkey - parameter to be passed to {@link KEYUTIL.getKey}&lt;/li>
<span class='line'>337</span>  * &lt;/ul>
<span class='line'>338</span>  *
<span class='line'>339</span>  * @example
<span class='line'>340</span>  * // 1) by key object
<span class='line'>341</span>  * pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
<span class='line'>342</span>  *   subject: {str: '/C=US/O=Test/CN=example.com'},
<span class='line'>343</span>  *   sbjpubkey: pubKeyObj,
<span class='line'>344</span>  *   sigalg: "SHA256withRSA",
<span class='line'>345</span>  *   sbjprvkey: prvKeyObj
<span class='line'>346</span>  * });
<span class='line'>347</span>  *
<span class='line'>348</span>  * // 2) by private/public key PEM 
<span class='line'>349</span>  * pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
<span class='line'>350</span>  *   subject: {str: '/C=US/O=Test/CN=example.com'},
<span class='line'>351</span>  *   sbjpubkey: pubKeyPEM,
<span class='line'>352</span>  *   sigalg: "SHA256withRSA",
<span class='line'>353</span>  *   sbjprvkey: prvKeyPEM
<span class='line'>354</span>  * });
<span class='line'>355</span>  *
<span class='line'>356</span>  * // 3) with generateKeypair
<span class='line'>357</span>  * kp = KEYUTIL.generateKeypair("RSA", 2048);
<span class='line'>358</span>  * pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
<span class='line'>359</span>  *   subject: {str: '/C=US/O=Test/CN=example.com'},
<span class='line'>360</span>  *   sbjpubkey: kp.pubKeyObj,
<span class='line'>361</span>  *   sigalg: "SHA256withRSA",
<span class='line'>362</span>  *   sbjprvkey: kp.prvKeyObj
<span class='line'>363</span>  * });
<span class='line'>364</span>  *
<span class='line'>365</span>  * // 4) by private/public key PEM with extension
<span class='line'>366</span>  * pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
<span class='line'>367</span>  *   subject: {str: '/C=US/O=Test/CN=example.com'},
<span class='line'>368</span>  *   ext: [
<span class='line'>369</span>  *     {subjectAltName: {array: [{dns: 'example.net'}]}
<span class='line'>370</span>  *   ],
<span class='line'>371</span>  *   sbjpubkey: pubKeyPEM,
<span class='line'>372</span>  *   sigalg: "SHA256withRSA",
<span class='line'>373</span>  *   sbjprvkey: prvKeyPEM
<span class='line'>374</span>  * });
<span class='line'>375</span>  */</span><span class="WHIT">
<span class='line'>376</span> </span><span class="NAME">KJUR.asn1.csr.CSRUtil.newCSRPEM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">param</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KEYUTIL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KEYUTIL</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_asn1_csr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.asn1.csr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>379</span> 
<span class='line'>380</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">param.subject</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"parameter subject undefined"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">param.sbjpubkey</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"parameter sbjpubkey undefined"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">param.sigalg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"parameter sigalg undefined"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">param.sbjprvkey</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"parameter sbjpubkey undefined"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>384</span> 
<span class='line'>385</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">csri</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_csr.CertificationRequestInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">    </span><span class="NAME">csri.setSubjectByParam</span><span class="PUNC">(</span><span class="NAME">param.subject</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">    </span><span class="NAME">csri.setSubjectPublicKeyByGetKey</span><span class="PUNC">(</span><span class="NAME">param.sbjpubkey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>388</span> 
<span class='line'>389</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">param.ext</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">param.ext.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">param.ext.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">	    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">param.ext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">                </span><span class="NAME">csri.appendExtensionByName</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">param.ext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>396</span> 
<span class='line'>397</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">csr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_KJUR_asn1_csr.CertificationRequest</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'csrinfo'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">csri</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prvKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KEYUTIL.getKey</span><span class="PUNC">(</span><span class="NAME">param.sbjprvkey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">    </span><span class="NAME">csr.sign</span><span class="PUNC">(</span><span class="NAME">param.sigalg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prvKey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>400</span> 
<span class='line'>401</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">csr.getPEMString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>403</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>404</span> 
<span class='line'>405</span> </span><span class="COMM">/**
<span class='line'>406</span>  * get field values from CSR/PKCS#10 PEM string&lt;br/>
<span class='line'>407</span>  * @name getInfo
<span class='line'>408</span>  * @memberOf KJUR.asn1.csr.CSRUtil
<span class='line'>409</span>  * @function
<span class='line'>410</span>  * @param {String} sPEM PEM string of CSR/PKCS#10
<span class='line'>411</span>  * @returns {Object} JSON object with parsed parameters such as name or public key
<span class='line'>412</span>  * @since jsrsasign 6.1.3 asn1csr 1.0.1
<span class='line'>413</span>  * @description
<span class='line'>414</span>  * This method parses PEM CSR/PKCS#1 string and retrieves
<span class='line'>415</span>  * subject name and public key. Following parameters are available in the
<span class='line'>416</span>  * resulted JSON object.
<span class='line'>417</span>  * &lt;ul>
<span class='line'>418</span>  * &lt;li>subject.name - subject name string (ex. /C=US/O=Test)&lt;/li>
<span class='line'>419</span>  * &lt;li>subject.hex - hexadecimal string of X.500 Name of subject&lt;/li>
<span class='line'>420</span>  * &lt;li>pubkey.obj - subject public key object such as RSAKey, KJUR.crypto.{ECDSA,DSA}&lt;/li>
<span class='line'>421</span>  * &lt;li>pubkey.hex - hexadecimal string of subject public key&lt;/li>
<span class='line'>422</span>  * &lt;/ul>
<span class='line'>423</span>  *
<span class='line'>424</span>  * @example
<span class='line'>425</span>  * o = KJUR.asn1.csr.CSRUtil.getInfo("-----BEGIN CERTIFICATE REQUEST...");
<span class='line'>426</span>  * console.log(o.subject.name) &rarr; "/C=US/O=Test"
<span class='line'>427</span>  */</span><span class="WHIT">
<span class='line'>428</span> </span><span class="NAME">KJUR.asn1.csr.CSRUtil.getInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sPEM</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ASN1HEX</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_getTLVbyList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ASN1HEX.getTLVbyList</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> 
<span class='line'>432</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">    </span><span class="NAME">result.subject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">    </span><span class="NAME">result.pubkey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> 
<span class='line'>436</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sPEM.indexOf</span><span class="PUNC">(</span><span class="STRN">"-----BEGIN CERTIFICATE REQUEST"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"argument is not PEM file"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>438</span> 
<span class='line'>439</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pemtohex</span><span class="PUNC">(</span><span class="NAME">sPEM</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"CERTIFICATE REQUEST"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>440</span> 
<span class='line'>441</span> </span><span class="WHIT">    </span><span class="NAME">result.subject.hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getTLVbyList</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">    </span><span class="NAME">result.subject.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">X509.hex2dn</span><span class="PUNC">(</span><span class="NAME">result.subject.hex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>443</span> 
<span class='line'>444</span> </span><span class="WHIT">    </span><span class="NAME">result.pubkey.hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_getTLVbyList</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">    </span><span class="NAME">result.pubkey.obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KEYUTIL.getKey</span><span class="PUNC">(</span><span class="NAME">result.pubkey.hex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"pkcs8pub"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>446</span> 
<span class='line'>447</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>448</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>449</span> 
<span class='line'>450</span> 
<span class='line'>451</span> </span></pre></body></html>